#include "widget.h"
#include "ui_widget.h"

#include <QMessageBox>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //1.修改窗口标题
    this->setWindowTitle("服务器");

    //2.创建QTcpServer的示例
    tcpServer =new QTcpServer(this);

    //3.通过信号槽，指定如何处理连接
    connect(tcpServer,&QTcpServer::newConnection,this,&Widget::processConnection);

    //4.绑定监听端口号，确保工作充分
    bool ret=tcpServer->listen(QHostAddress::Any,9090);
    if(!ret)
    {
        QMessageBox::critical(this,"服务器启动失败",tcpServer->errorString());
        exit(1);
    }
}

Widget::~Widget()
{
    delete ui;
}

void Widget::processConnection()
{

}

